{% extends 'main_frame.html' %}

{% block content %}
{% include "search.html" %}
<table class="layui-hide" id="LAY_table" lay-filter="LAY_table"></table>
<script type="text/html" id="LAY_bar">
    <a class="layui-btn layui-btn-xs" lay-event="view" title="">查看</a>
    <!--<a class="layui-btn layui-btn-xs" lay-event="edit" title="">修改</a>-->
    <!--<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delete" title="">删除</a>-->
</script>
{% endblock %}


{% block js %}
<script>

    var cols=[[

        {type: 'numbers',title: '序号',width: 60},
        {field:'userName',title: '用户名',width: 150},
        {field:'orderSn',title: '订单编号',width: 150},
        {field:'orderStatus',title: '订单状态',width: 150},
        {field:'shippingStatus',title: '发货状态',width: 150},
        {field:'payStatus',title: '支付状态',width: 150},
        {field:'shippingName',title: '物流名称',width: 150},
        {field:'payName',title: '支付方式',width: 150},
        {field:'totalPrice',title: '商品总价',width: 150},
        {field:'shippingPrice',title: '邮费',width: 150},
        {field:'actualPrice',title: '实际价格',width: 150},
        {field:'integral',title: '使用积分数',width: 150},
        {field:'coupon',title: '使用优惠券',width: 150},
        {field:'addTime',title: '下单时间',width: 150},
        {field:'shippingTime',title: '发货时间',width: 150},
        {field:'confirmTime',title: '收货时间',width: 150},
        {field:'payTime',title: '支付时间',width: 150},
        {field:'consigneeName',title: '收货人',width: 150},
        {field:'consigneePhone',title: '收货人手机号码',width: 150},
        {field:'consigneeAddress',title: '收货地址',width: 150},
        {field:'btns',title: '操作',align: 'center',toolbar: '#LAY_bar',event:'click',fixed: 'right',width:80}
    ]]

    //监听工具栏
    layui.table.on('tool(LAY_table)', function(obj) {
        var data = obj.data;
        switch(obj.event){
            //查看
            case 'view' :
                Methods.view(data);
                break;
            //修改
            case 'edit' :
                Methods.info(data);
                break;
            //删除
            case 'delete' :
                Methods.delete(data);
                break;

            default:
                break;
        }
    });
    //方法集合
    var Methods={
        render:function(where){
            layui.table.render({
                elem: '#LAY_table',
                method:'POST',
                contentType:'application/json',
                url:API.order.list,
                where:where,
                cols: cols,
                id: 'LAY_table',
                page: true,
                limits: [10, 15, 20, 30, 40, 50],
                loading: true,
                height: FX.getWinHeight(74),
                skin: '', //行边框风格
                even: true, //开启隔行背景
                size: 'big', //小尺寸的表格
                done:function(){

                }
            });
        },
        view:function(data){
            layer.open({
                type: 1,
                title:'信息',
                btn: ['关闭'],
                area:['640px','400px'],
                shadeClose:true,
                anim:5,
                content:function(){
                    return FX.getView({
                        '用户名':data.userName,
                        '订单编号':data.orderSn,
                        '订单状态':data.orderStatus,
                        '发货状态':data.shippingStatus,
                        '支付状态':data.payStatus,
                        '物流名称':data.shippingName,
                        '支付方式':data.payName,
                        '商品总价':data.totalPrice,
                        '邮费':data.shippingPrice,
                        '实际价格':data.actualPrice,
                        '下单时间':data.addTime,
                        '发货时间':data.shippingTime,
                        '收货时间':data.confirmTime,
                        '支付时间':data.payTime,
                        '收货人':data.consigneeName,
                        '收货人手机号码':data.consigneePhone,
                        '收货地址':data.consigneeAddress
                    })
                }(),
                yes:function(index, layero){
                    layer.close(index);
                },
                end:function(){

                },
                success:function(layero,index){

                }
            });
        },
        info:function(obj){
            FX.ajax({
                url:API.order.info + obj.orderId,
                success:function(res){
                    if(res.code==0){
                        Methods.edit(res.data)
                    }
                }
            })
        }
    }
    $("#add_user").click(function(){
        Methods.add();
    })


    Methods.render();
    FX.getSearch(WHERE.orderList,Methods.render);

</script>
{% endblock %}